<template>
  <el-dialog title="优惠券信息" :visible.sync="dialogVisible" width="80%" append-to-body :before-close="closeCoupon" :close-on-click-modal="false">
    <div>
      <ul class="coupon-list">
        <li v-for="(coupon, index) in couponList" :key="index">
          <div class="name">{{ coupon.scope }}</div>
          <div class="description">{{ coupon.couponFaceDescription }}</div>
          <div class="date">{{ coupon.withAvailable}} {{ coupon.startAndEndTime }}</div>
          <div class="discount">{{ coupon.faceValue}}</div>
        </li>
      </ul>
    </div>
    <div slot="footer" class="text-center">
      <el-button @click="closeCoupon">关  闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getCouponList } from '@/api/mx/order'

export default {
  name: 'index',
  props: {
    dialogVisible: {
      default: false
    },

   /*  couponList:{
      default:null
    }
 */
  },
  data(){
    return{
      couponList: null
    }
  },
  methods:{
    /**
     * 查看免息券
     */
    getCoupon(row){
      getCouponList(row).then(res=>{
        if (res.code === 200) {
          this.couponList=res.data
        }
      }).catch()

    },
    closeCoupon(){
     this.$emit('closeCoupon')
    },
  },
}
</script>

<style scoped>
/*优惠券css*/
.coupon-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.coupon-list li {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  height: 120px;
  justify-content: center;
  margin: 10px;
  padding: 10px;
  overflow: hidden;
}

.name {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.description {
  font-size: 14px;
  color: #666;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.date {
  font-size: 14px;
  color: #666;
  margin-top: 5px;
}

.discount {
  font-size: 20px;
  font-weight: bold;
  color: #ff6b6b;
  margin-top: 5px;
}
</style>
